import request from '@/utils/request'

export default {
  getPositionList(searchModel) {
    return request({
      url: '/position/list',
      method: 'get',
      params: {
        page: searchModel.page,
        pageSize: searchModel.pageSize,
        name: searchModel.name
      }
    })
  },
  addPosition(position) {
    return request({
      url: '/position',
      method: 'post',
      data: position
    })
  },
  getPositionById(id) {
    return request({
      // url: '/Position/' + id,
      url: `/position/${id}`,
      method: 'get'
    })
  },
  updatePosition(position) {
    return request({
      url: '/position',
      method: 'put',
      data: position
    })
  },
  savePosition(position) {
    if (position.id == null && position.id === undefined) {
      return this.addPosition(position)
    }
    return this.updatePosition(position)
  },
  deletePosition(id) {
    return request({
      // url: '/user/' + id,
      url: `/position/${id}`,
      method: 'delete'
    })
  },
  getDepartmentName(params) {
    return request({
      url: '/department/name',
      method: 'get',
      params
    })
  },
}
